package enums.effective;

public enum PayrollDay {

	MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY,
	SATURDAY(PayType.WEEKEND), SUNDAY(PayType.WEEKEND)
	;
	
	private final PayType payType;
	
	PayrollDay(PayType PayType) { this.payType = PayType; }
	
	private PayrollDay() {
		this(PayType.WEEKDAY);
	}
	
	int pay(int minsWorked, int payRate) {
		return payType.pay(minsWorked, payRate);
	}
	
	public static void main(String[] args) {
	}
}

enum PayType {
	
	WEEKDAY {
		@Override
		int overtimePay(int minsWorked, int payRate) {
			return minsWorked <= MINS_PER_SHIFT ? 0 : (minsWorked - MINS_PER_SHIFT) * payRate / 2;
		}
	},
	
	WEEKEND {
		@Override
		int overtimePay(int minsWorked, int payRate) {
			return minsWorked * payRate / 2;
		}
	};
	
	abstract int overtimePay(int minsWorked, int payRate);
	
	private static final int MINS_PER_SHIFT = 8 * 60;
	
	int pay(int minsWorked, int payRate) {
		int basePay = minsWorked * payRate;
		return basePay + overtimePay(minsWorked, payRate);
	}
}